package cn.edu.scau.cmi.liyetian.client;

import java.util.Scanner;

import cn.edu.scau.cmi.liyetian.composite.consistent.*;

public class ConsistentCompositeClient {
public static void main(String[] args) {
		
		Team team = new Team("T1");
		Person personNew = null;
		Team teamNew = null;
		Team teamNew2 = null;
		
		Scanner scanner = new Scanner(System.in);  
		String brand = "";
		while(true) {
			System.out.println("你想创建个人还是团队？创建个人输入1，创建团队输入2，结束程序输出3");
			brand = scanner.next();
			if(brand.equals("1")) {
				//create person
				System.out.println("请输入个人的名字");
				brand = scanner.next();
				personNew = new Person(brand);
				
				System.out.println("请输入想要加入的团体");
				brand = scanner.next();
				teamNew = team.findTeam(brand);
				if(teamNew == null) {
					System.out.println("找不到团体");
				}
				else {
					teamNew.addPerson(personNew);
					System.out.println("加入成功");
					System.out.println(team.showMember());
				}
				
				
			}
			else if(brand.equals("2")){
				//create team
				System.out.println("请输入团体名字");
				brand = scanner.next();
				teamNew = new Team(brand);
				
				System.out.println("请输入想要加入的团体");
				brand = scanner.next();
				teamNew2 = team.findTeam(brand);
				if(teamNew2 == null) {
					System.out.println("找不到团体");
				}
				else {
					teamNew2.addTeam(teamNew);
					System.out.println("加入成功");
					System.out.println(team.showMember());
				}
				
			}
			else if(brand.equals("3")){
				//finish create
				System.out.println("程序结束");
				break;
			}
			else if(brand.equals("4")){
				//finish create
				System.out.println(team.showMember());
			}
			else {
				System.out.println("无效输入");
			}
		}
	}
}
